﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Minecraft_Armor_Stand_Creater.Util
{
    /// <summary>
    /// 单例懒加载
    /// </summary>
    /// <typeparam name="T">单例类</typeparam>
    public abstract class Singleton<T> where T : Singleton<T>, new()
    {
        // 单例类
        protected Singleton() { }

        // 创建唯一对象
        protected static readonly Lazy<T> lazy = new(() => new T());

        // 对外唯一实例
        public static T Instance { get { return lazy.Value; } }
    }
}
